package com.resrun.enums;

import lombok.Getter;

@Getter
public enum CertFormatEnum {

    PEM((byte) 1, "PEM"),
    DER((byte) 2, "DEM"),
    PKCS12((byte) 3, "PKCS12");


    private final byte type;
    private final String name;

    CertFormatEnum(byte type, String name) {
        this.type = type;
        this.name = name;
    }

    public static CertFormatEnum of(byte state) {
        for (CertFormatEnum caStateEnum : CertFormatEnum.values()) {
            if (caStateEnum.type == state) {
                return caStateEnum;
            }
        }

        return null;
    }

    public static CertFormatEnum of(String name) {
        for (CertFormatEnum caStateEnum : CertFormatEnum.values()) {
            if (caStateEnum.name.equalsIgnoreCase(name)) {
                return caStateEnum;
            }
        }

        return null;
    }

}
